﻿<Window x:Class="JellystonePark.JellystoneWPF.View.JellystoneWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:resx="clr-namespace:JellystonePark.JellystoneLib;assembly=JellystoneLib"
        Title="Maci Laci V2" Height="300" Width="300" WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <Style TargetType="MenuItem" x:Key="MenuItemStyle">
            <Style.Setters>
                <Setter Property="Padding" Value="3, 0, 3, 2"/>
            </Style.Setters>
        </Style>
    </Window.Resources>
    <Window.InputBindings>
        <KeyBinding Key="P" Command="{Binding ToggleCommand}"/>
        <KeyBinding Key="Left" Command="{Binding LeftCommand}"/>
        <KeyBinding Key="Up" Command="{Binding UpCommand}"/>
        <KeyBinding Key="Right" Command="{Binding RightCommand}"/>
        <KeyBinding Key="Down" Command="{Binding DownCommand}"/>
    </Window.InputBindings>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Menu Grid.Row="0">
            <MenuItem Header="Fájl" Style="{StaticResource MenuItemStyle}">
                <MenuItem Header="Új játék" Command="{Binding NewGameCommand}"/>
                <MenuItem Header="Pályacsomag betöltése" Command="{Binding LoadLevelsCommand}"/>
                <Separator/>
                <MenuItem Header="Kilépés"  Command="{Binding ExitCommand}"/>
            </MenuItem>
        </Menu>
        <ItemsControl ItemsSource="{Binding Fields}" Grid.Row="1">
            <ItemsControl.ItemTemplate>
                <DataTemplate DataType="vm:JellystoneField">
                    <Button Content="{Binding Value}">
                        <Button.Template>
                            <ControlTemplate TargetType="Button">
                                <Border CornerRadius="8" Margin="1">
                                    <Border.Style>
                                        <Style TargetType="Border">
                                            <Setter Property="BorderThickness" Value="1"/>
                                            <Setter Property="Background" Value="LightGray"/>
                                        </Style>
                                    </Border.Style>
                                    <TextBlock Text="{Binding Value}">
                                        <TextBlock.Style>
                                            <Style TargetType="TextBlock">
                                                <Setter Property="VerticalAlignment" Value="Center" />
                                                <Setter Property="HorizontalAlignment" Value="Center" />
                                                <Setter Property="FontFamily" Value="Arial" />
                                                <Setter Property="FontSize" Value="30" />
                                            </Style>
                                        </TextBlock.Style>
                                    </TextBlock>
                                </Border>
                            </ControlTemplate>
                        </Button.Template>
                    </Button>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <UniformGrid Rows="{Binding SideLength}" Columns="{Binding SideLength}" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemContainerStyle>
                <Style>
                    <Setter Property="Grid.Column" Value="{Binding Y}"/>
                    <Setter Property="Grid.Row" Value="{Binding X}"/>
                </Style>
            </ItemsControl.ItemContainerStyle>
        </ItemsControl>

        <StatusBar Grid.Row="2">
            <StatusBarItem>
                <TextBlock Text="Játékidő: " />
            </StatusBarItem>
            <StatusBarItem>
                <TextBlock Text="{Binding ElapsedTime}" />
            </StatusBarItem>
                <Separator/>
            <StatusBarItem>
                <TextBlock Text="Lépések: " />
            </StatusBarItem>
            <StatusBarItem>
                <TextBlock Text="{Binding Steps}" />
            </StatusBarItem>
            <Separator/>
            <StatusBarItem>
                <TextBlock Text="Kosarak: " />
            </StatusBarItem>
            <StatusBarItem>
                <TextBlock Text="{Binding BasketsFounded}" />
            </StatusBarItem>
        </StatusBar>
    </Grid>
</Window>
